import {requestModel} from'../../model/classicModel.js'
let request = new requestModel()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    classic:{},
    imge:"/components/classic/movie/img/k1.png",
    previous:true,
    next:false,
    index:Number,
    noShow:true,
    show:false,
    hidden:Boolean
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    request.getLatest(this.callBack)
  },
  callBack:function(rec){
    let index = this.data.index
    this.setData(
      this.data.classic =rec,
    )
  console.log(rec)
    this.data.index = rec.index
    console.log(this.data.index)
  },
  onLike: function (event) {
    if(event.detail.bihevior==='like'){
    }else{
    }
  },
  onNext:function(){
    let index = this.data.index
    request.upDate(--index,this.callBack)
    this.setData({
      next: request.isNext(index),
      previous: request.isPrevious(index)
    })
  },
  onPrevious:function(){
    let index = this.data.index
    request.upDate(++index, this.callBack)
    this.setData({
      next: request.isNext(index),
      previous: request.isPrevious(index)
    })
    console.log(this.data.index)
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  
  /**
   * 生命周期函数--监听页面隐藏
   */
  // onHide: function () {

  // },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})